//
//  VisitorTableViewController.m
//  weibo110
//
//  Created by 臧松 on 15/12/26.
//  Copyright © 2015年 臧松. All rights reserved.
//

#import "VisitorTableViewController.h"
#import "VisitorView.h"
#import "OAuthViewController.h"
#import "UserAccountViewModel.h"
@interface VisitorTableViewController ()
// 用户登录标记
@property (nonatomic,assign,getter=isUserLogon) BOOL userLogon;

@end

@implementation VisitorTableViewController

- (void)loadView{
    self.userLogon = [UserAccountViewModel shareUserAccount].userLogon;
    
    if (self.userLogon) {
        
        [super loadView];
    }else{
        [self setupVisitorView];
    }
    
}
// 设置访客登录视图
-(void)setupVisitorView{
    //  替换根视图
    self.visitorView = [[VisitorView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    
    self.view = self.visitorView;
    [self.visitorView.registerButton addTarget:self action:@selector(resgisterClick) forControlEvents:UIControlEventTouchUpInside];
    [self.visitorView.loginButton addTarget:self action:@selector(logonClick) forControlEvents:UIControlEventTouchUpInside];
    
    // 设置导航栏按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style: UIBarButtonItemStylePlain target:self action:@selector(resgisterClick)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"登录" style: UIBarButtonItemStylePlain target:self action:@selector(logonClick)];
    // self.view.backgroundColor = [UIColor redColor];

}

-(void)resgisterClick{
    
    NSLog(@"注册了");
}
-(void)logonClick{
    
    NSLog(@"登录了");
    OAuthViewController* vc = [[OAuthViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:nav animated:YES completion:nil];

}
@end
